package com.ymttest.database.sqlwapper.godmch;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.collections.map.HashedMap;

import com.ymt.database.SqlManager;
import com.ymttest.database.model.invite_code;
import com.ymttest.utils.EnvSetup;
/************************************************************************************
 * @File name : invite_codeWapperWapper.java
 * @Author : 吴文
 * @Date : 
 * @Copyright : 洋码头
 *godmach
 ************************************************************************************/
public class invite_codeWapper {
	SqlManager manage;
	public invite_codeWapper() {
		manage = new SqlManager("mysqlgodmchdb" + EnvSetup.getEnv());
		 
	}
		
	public  List<invite_code> selectby(Map<String,Object> map) throws InterruptedException {
		List<invite_code> list = manage.getSelectResults("com.ymttest.database.mapping.godmch.invite_codeMapper.selectby",map);
		manage.commit();
		return list;
	}
	
	
	public  invite_code selectByPrimaryKey(Integer seqId) {
		invite_code model=new invite_code();
		List<invite_code> list = manage.getSelectResults("com.ymttest.database.mapping.godmch.invite_codeMapper.selectByPrimaryKey",seqId);
		manage.commit();
		if(list.size()>0)
		    model=list.get(0);
		return model;	
	}
	public  invite_code selectByCode(String code) {
		invite_code model=new invite_code();
		List<invite_code> list = manage.getSelectResults("com.ymttest.database.mapping.godmch.invite_codeMapper.selectByCode",code);
		manage.commit();
		if(list.size()>0)
		    model=list.get(0);
		return model;	
	}
	public  int updateExpireByCode(String code,Date expireTime) {
		HashMap<String,Object> map=new HashMap<String,Object>();
		map.put("inviteCode", code);
		map.put("expireTime", expireTime);
		int result= manage.update("com.ymttest.database.mapping.godmch.invite_codeMapper.updateExpireByCode",map);
		manage.commit();
		return result;	
	}
	
	public static void main(String args[]) throws InterruptedException {

		invite_codeWapper codeWapper=new invite_codeWapper();
		Map<String,Object> map=new HashedMap();
		map.put("inviteCode", "BWW62");
		List<invite_code> codes=codeWapper.selectby(map);
		System.out.print(codes.size());
	}
}
